<template>
  <div>
    <div class="nav">
      <img :src="headimgurl" alt="" class="head" />
      <div class="name">{{ nickname }}</div>
    </div>
    <div class="box1">
      <div class="left">
        <div class="count">{{ count }}</div>
        <div class="countTxt">推广人数</div>
      </div>
      <div class="right">
        <div class="redPacket">{{ redPacket }}</div>
        <div class="redPacketTxt">红包金额</div>
      </div>
    </div>
    <van-tabs v-model="active" @click="onClick">
      <van-tab title="订单">
        <van-empty description="暂无订单" v-if="order.length == 0" />
        <div class="extendList">
          <span class="tou">用户头像</span>
          <span class="nickname">昵称</span>
          <span class="order">订单金额</span>
        </div>
        <div class="extendList" v-for="(item, index) in order" :key="index">
          <img :src="headimgurl" alt="" class="head" />
          <span class="nickname">{{ nickname }}</span>
          <span class="order">{{ item.orderMoney / 100 }}元</span>
        </div>
      </van-tab>
      <van-tab title="推广" @click="_getMineExtend">
        <van-empty description="暂无推广" v-if="extendList.length == 0" />
        <div class="extendList">
          <span class="tou">用户头像</span>
          <span class="nickname">昵称</span>
          <span class="order">红包金额</span>
        </div>
        <div
          class="extendList"
          v-for="(item, index) in extendList"
          :key="index"
        >
          <img :src="item.headimgurl" alt="" class="head" />
          <span class="nickname">{{ item.nickname }}</span>
          <span class="order">{{ item.redPacket / 100 }}元</span>
        </div>
      </van-tab>
      <van-tab title="关注">
        <van-empty description="暂无关注" />
      </van-tab>
    </van-tabs>
  </div>
</template>

<script lang="ts">
import { Vue, Component } from "vue-property-decorator";
import { getMineInfo, getMineExtend } from "@/api/index";

@Component
export default class Mine extends Vue {
  count: number = 0; // 推广人数
  redPacket: number = 0; // 红包金额
  order: any = []; // 订单列表
  nickname: string = ""; // 昵称
  headimgurl: string = ""; // 头像
  ExtendHeadUrl: string = "";
  ExtendNickname: string = "";
  ExtendRedPacket: any = "";
  active: number = 0;
  extendList: any = [];
  created() {
    this._getMineInfo();
  }
  _getMineInfo() {
    getMineInfo().then((res) => {
      console.log("res", res);
      this.count = res.data.count;
      this.order = res.data.order;
      this.headimgurl = res.data.headimgurl;
      this.nickname = res.data.nickname;
      this.redPacket = res.data.redPacket;
    });
  }
  _getMineExtend() {
    getMineExtend().then((res) => {
      console.log("res", res);
      this.extendList = res.data.extendList;
    });
  }
  onClick(name: any, title: any) {
    if (title == "推广") {
      this._getMineExtend();
    }
  }
}
</script>

<style lang="less">
.nav {
  width: 100%;
  height: 191px;
  background-image: url("../assets/nav-11.png");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center center;
  .head {
    width: 80px;
    border-radius: 50%;
    border: 5px solid rgba(255, 255, 255, 0.5);
    margin-top: 40px;
  }
  .name {
    font-size: 18px;
    margin-top: 10px;
  }
}
.box1 {
  overflow: hidden;
  margin-top: 20px;
  .left {
    width: 50%;
    float: left;
    .count {
      font-size: 16px;
      font-weight: 700;
    }
    .countTxt {
      font-size: 16px;
    }
  }
  .right {
    width: 50%;
    float: right;
    .redPacket {
      font-size: 16px;
      font-weight: 700;
    }
    .redPacketTxt {
      font-size: 16px;
    }
  }
}
.extendList {
  width: 100%;
  overflow: hidden;
  padding: 10px 0;
  span {
    height: 30px;
    line-height: 30px;
    font-size: 18px;
    float: left;
    font-size: 16px;
  }
  .index {
    width: 10%;
  }
  .nickname {
    width: 50%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    text-align: center;
    font-size: 14px;
    color: #333;
    font-weight: 700;
  }
  img {
    border-radius: 50%;
    width: 40px;
    float: left;
    margin: 0 15px;
  }
  .order {
    width: 30%;
    font-size: 14px;
    color: #333;
    font-weight: 700;
    float: right;
  }
  .tou {
    width: 70px;
    padding: 0;
    font-size: 14px;
    color: #333;
    font-weight: 700;
  }
}
[class*="van-hairline"]::after {
  border: none;
}
</style>
